#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e5 + 5;

int n, m;
int a[N];
struct Node {
  int sum, mxl, mxr, mx;
} tr[N << 2];
Node merge(Node a, Node b) {
  Node res;
  res.sum = a.sum + b.sum;
  res.mxl = max(a.mxl, a.sum + b.mxl);
  res.mxr = max(b.mxr, b.sum + a.mxr);
  res.mx = max({a.mx, b.mx, a.mxr + b.mxl});
  return res;
}
void build(int p, int l, int r) {
  if (l == r) {
    tr[p] = Node{a[l], a[l], a[l], a[l]};
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  tr[p] = merge(tr[p << 1], tr[p << 1 | 1]);
}
void update(int pos, int val, int p, int l, int r) {
  if (l == r) {
    tr[p] = Node{val, val, val, val};
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(pos, val, p << 1, l, mid);
  else
    update(pos, val, p << 1 | 1, mid + 1, r);
  tr[p] = merge(tr[p << 1], tr[p << 1 | 1]);
}
Node query(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return tr[p];
  int mid = (l + r) >> 1;
  if (R <= mid)
    return query(L, R, p << 1, l, mid);
  else if (L > mid)
    return query(L, R, p << 1 | 1, mid + 1, r);
  else {
    Node x = query(L, R, p << 1, l, mid);
    Node y = query(L, R, p << 1 | 1, mid + 1, r);
    return merge(x, y);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  build(1, 1, n);
  while (m--) {
    int op, x, y;
    cin >> op >> x >> y;
    if (op == 1) {
      if (x > y) swap(x, y);
      cout << query(x, y, 1, 1, n).mx << endl;
    } else
      update(x, y, 1, 1, n);
  }
  return 0;
}